package com.enhe.gck.fg;

import com.alibaba.fastjson.JSON;
import com.enhe.gck.communal.PublicConstant;
import com.enhe.gck.communal.PublicMethod;
import com.kuangkie.carbon.fg.*;
import com.kuangkie.carbon.record.FGRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import com.kuangkie.carbon.record.FGRecordComplexus;
import com.kuangkie.carbon.record.ProRecord;
import com.enhe.gck.CarbonBaseConstant; //模型Code
import com.enhe.gck.CarbonEnumKeyValue; //枚举字典信息
import com.enhe.gck.CarbonRelationType; //关系类型Code
import com.enhe.gck.item.MaterialAllHWANE19162Item; // 模型属性Code

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@Repository(value = "hwane19162366042330866425862")
public class MaterialAllHWANE19162BNB implements SecondRoundImproveFuncGroup, FetchFuncGroup {

	private static final Logger log = LoggerFactory.getLogger(MaterialAllHWANE19162BNB.class);
	@Resource
	private ConfigHWANE16627BNB configHWANE16627BNB;

	@Override
	public void secondImprove(FuncGroupContext context, ProRecord proRecord, FGRecordComplexus recordComplexus,
			ImproveResultFactory improveResultFactory) {
	}

	@Override
	public void fetchImprove(FuncGroupContext funcGroupContext, FGRecord fgRecord, FetchResultFactory fetchResultFactory) {
		String nameCode=configHWANE16627BNB.getConfigValueNameCode();
		String name="空";
		try {
			List<Map> names= JSON.parseArray(fgRecord.getString(MaterialAllHWANE19162Item.基本属性组_NS物料名称),Map.class);
			for (Map map : names) {
				if(map.get(nameCode)!=null){
					name=map.get(nameCode).toString();
					break;
				}
			}
		}catch (Exception e) {
			log.info("数据异常,{}",fgRecord);
		}
		fetchResultFactory.getRecordOpsBuilder()
				.putAttribute(MaterialAllHWANE19162Item.基本属性组_名称,name);
	}
}
